import { defineStore } from 'pinia'
import type { ConfigProviderThemeVars, ConfigProviderTheme } from 'wot-design-uni'
export const useThemeStore = defineStore('theme', {
  state: () => ({
    theme: 'light' as ConfigProviderTheme,
    themeVars: {
      //   colorTheme: '#10C595',
      //   buttonPrimaryBgColor: '#10C595',
      //   buttonPrimaryColor: '#ffffff',
    } as ConfigProviderThemeVars,
  }),

  actions: {
    setTheme(theme: ConfigProviderTheme) {
      this.theme = theme
    },
    setThemeVars(vars: Partial<ConfigProviderThemeVars>) {
      this.themeVars = { ...this.themeVars, ...vars }
    },
  },
  persist: {
    storage: {
      setItem(key, value) {
        uni.setStorageSync(key, value)
      },
      getItem(key) {
        return uni.getStorageSync(key)
      },
    },
  },
})
